<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="divport" content="width=device-width, initial-scale=1.0">
    <title>保亿家</title>
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="./css/main.css">
    <link rel="stylesheet" href="./css/reset.css">
    <link rel="stylesheet" href="./css/utils.css">
    <link rel="stylesheet" href="./dist/css/swiper.min.css">
</head>

<body>
    <div class="getheight">
        <!-- 头部消息 -->
        <div class="title">
            <div class="title1">
                <!-- <van-icon class="icon" name="volume" />-->

                <img src="./img/广播信息.png" alt=""> 深耕互联网科技生活，尊享高品质服务保障</div>
            <div class="title2">

                <image width=" 100%" src="./img/铃铛.png"></image>

            </div>

        </div>
        <div class="swiper">
            <div class="swiper-container">
                <div class="swiper-wrapper">
                    <!-- <div class="swiper-slide">
                        <img width="100%" src="./img/1.png" alt="">
                    </div> -->
                    <div class="swiper-slide">
                        <img width="100%" src="./img/banner3.png" alt="">
                    </div>
                </div>

            </div>
            <!-- 轮播图下面的点 -->
            <!-- Add Pagination -->
            <!-- <div class="swiper-pagination"></div> -->
        </div>

        <!-- 首页轮播 -->
        <!-- <div class="swiper">
            <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}"
                duration="{{duration}}">
                <block wx:for="{{background}}" wx:key="*this">
                    <swiper-item>
                        <div class="swiper-item">
                            <image style="width:100%;height:300rpx;" src="{{item.path}}"></image>
                        </div>
                    </swiper-item>
                </block>
            </swiper>
        </div> -->
        <div class="blue">
        </div>
        <!-- 中间五张图 -->
        <div class="content">
            <!-- <div class="horizontal">
            <div class="content-top1">盛大欢迎你</div>
            <div  class="content-top2"></div>
            <div class="content-top3">体验更快，更准，更贴心的车险服务</div>
        </div> -->
            <div class="content-">
                <div class="content-left">
                    <image bindtap="toPage" data-path="/pages/carInsurance/carinsurance" style="width:100%;height:100%"
                        src="./img/topay.png"></image>
                </div>
                <div class="content-middle">
                    <div class="content-middle1">
                        <image bindtap="toPage" class="topay" data-path="/pages/pay/pay" style="width:100%;height:100%"
                            src="./img/tocar.png"></image>
                    </div>
                    <div class="content-middle2">
                        <image bindtap="toPage" data-path="" style="width:100%;height:100%" src="./img/4.png">
                        </image>
                    </div>
                </div>
                <div class="content-right">
                    <div class="content-right1">
                        <image bindtap="toPage" data-path="" style="width:100%;height:100%" src="./img/5.png">
                        </image>
                    </div>
                    <div class="content-right2">
                        <image bindtap="toPage" data-path="" style="width:100%;height:100%" src="./img/6.png">
                        </image>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 符号前后必须有空格 -->
    <!-- 括号前后不能有空格 -->
    <div class="clac" style="flex:1;background:#f4f4f4;">
        <image class="bottomimg" style="width:100%;height:100rpx" src="./img/red底图.png"></image>
    </div>
    <div class="shadow"></div>
    <div class="alert">
        <div class="alert1">提示</div>
        <div class="alert2">正在拼命开发中。。。</div>
        <div class="alert-select">
            <!-- <div class="cancel">取消</div> -->
            <div class="confirm1">确定</div>
        </div>
    </div>
</body>

</html>
<script src="./js/rem.js"></script>
<script src="./js/jquery.min.js"></script>
<script src="./js/url.js"></script>
<script src="./js/rotate.js"></script>
<!-- Swiper JS -->
<script src="./dist/js/swiper.min.js"></script>

<!-- Initialize Swiper -->
<script>
    //轮播图
    var swiper = new Swiper('.swiper-container', {
        pagination: '.swiper-pagination',
        paginationClickable: true,
        autoplay: 3000,
    });

</script>
<script>
    var topay = document.querySelector(".topay")

    var img1 = document.querySelector(".content-left")
    var img3 = document.querySelector(".content-middle2")

    var img4 = document.querySelector(".content-right1")
    var img5 = document.querySelector(".content-right2")

    var shadow = document.querySelector(".shadow")
    var alertbox = document.querySelector(".alert")
    var confirm = document.querySelector(".confirm1")
    var body = document.querySelector("body")
    var img = document.querySelectorAll("img")
    for (var i = 0; i < img.length; i++) {
        var timestamp = Date.parse(new Date());

        img[i].src = img[i].src + '?' + timestamp
    }

    if (!is_weixin()) {
        console.log("不是从微信进入的")
        body.style.display = "block"
        body.innerHTML = `<div style="margin-top:0.2rem;margin-left:0.2rem">请从正确入口进入<div>`

    }

    topay.onclick = function () {
        shadow.style.display = "block"
        alertbox.style.display = "flex"
    }

    var openid = formatUndefined(GetRequest().openid)
    console.log("ss", GetRequest().openid)
    var uid = formatUndefined(GetRequest().uid)

    console.log(GetRequest().uid)
    img1.onclick = function () {
        var timestamp = Date.parse(new Date());
        window.location.href = 'pay.html?_=' + timestamp
    }
    img3.onclick = function () {
        shadow.style.display = "block"
        alertbox.style.display = "flex"

    }
    img4.onclick = function () {
        shadow.style.display = "block"
        alertbox.style.display = "flex"

    }
    img5.onclick = function () {
        shadow.style.display = "block"
        alertbox.style.display = "flex"

    }
    confirm.onclick = function () {
        shadow.style.display = "none"
        alertbox.style.display = "none"
    }


    // 先判断url 地址  为空 则获取本地
    if (openid) {
        $.ajax({
            method: "post",
            url: url + "?s=App.BYJTel.UserLogin",
            data: {
                openid: openid,
                uid: uid
            },
            dataType: 'json',
            success: (res) => {
                console.log("成功", res)

                if (res.data.errCode == 0) {
                    body.style.display = "block"
                    localStorage.setItem("openid", openid);
                    localStorage.setItem("uid", uid);
                } else {
                    body.style.display = "block"
                    body.innerHTML = `<div style="margin-top:0.2rem;margin-left:0.2rem">请从正确入口进入<div>`
                }
            },//成功后的回调函数
            error: (res) => {
                console.log("失败", JSON.stringify(res))
            }//失败后的回调函数
        }
        )
    }
    else if (localStorage.getItem("openid")) {
        openid = localStorage.getItem("openid")
        uid = localStorage.getItem("uid")
        $.ajax({
            method: "post",
            url: url + "?s=App.BYJTel.UserLogin",
            data: {
                openid: openid,
                uid: uid
            },
            dataType: 'json',
            success: (res) => {
                console.log("成功", res)
                body.style.display = "block"
                // if (res.data.errCode == 0) {
                //     body.style.display = "block"
                //     localStorage.setItem("openid", openid);
                //     localStorage.setItem("uid", uid);
                // } else {
                //     body.style.display = "block"
                //     body.innerHTML = `<div style="margin-top:0.2rem;margin-left:0.2rem">请从正确入口进入<div>`
                // }
            },//成功后的回调函数
            error: (res) => {
                console.log("失败", JSON.stringify(res))
            }//失败后的回调函数
        }
        )

    } else {
        body.style.display = "block"
        body.innerHTML = `<div style="margin-top:0.2rem;margin-left:0.2rem">请从正确入口进入<div>`
    }




    // 如果undefined 则返回空
    function formatUndefined(data) {
        if (data == undefined || data == "undefined") {
            return ""
        }
        return data
    }
    //判断是否为微信客户端
    function is_weixin() {
        var ua = navigator.userAgent.toLowerCase();
        console.log("aa", ua)
        if (ua.match(/MicroMessenger/i) == "micromessenger")
            return true;
        else
            return false;
    }
    function GetRequest() {

        var url = location.search;
        //获取url中"?"符后的字串  
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);

            }
        }
        return theRequest;

    }
</script>